Skip to content

feat(record): write only the unique id selector for recorded steps - #4733

Merged
thymikee merged 1 commit into
mainfrom
t3/record-unique-id-only
Nov 19, 2026
Merged

thymikee merged 1 commit into
mainfrom
t3/record-unique-id-only

Conversation

@thymikee

@thymikee thymikee commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

A recorded element step whose id is unique on the recorded screen now writes only id="...". Other steps keep the existing || chain. Before: press 'id="x" || role="button" label="Go" || label="Go"'. After: press 'id="x"'. No flag. 13 files changed.

The new recordedSelectorExpression helper lives in @agent-device/selectors. The script writer and the drag recorder both call it. buildSelectorChainForNode itself is unchanged, so the chain shown in resolution disclosure and divergence suggestions stays the same. Docs updated: help scripting, replay-e2e.md, commands.md (drag), and target-annotation.md.

Safety check: I found no consumer that depends on the alternatives after a unique id.

  • Replay with target-v1: "A recorded id never matches a node without that id" (target-annotation.md Local identity). So falling through to label= already ends in identity-mismatch.
  • Unannotated steps (fill --record-as drops its evidence): the fall-through was a silent re-bind (rejected by ADR 0012).
  • wait/is record the selector the user wrote, not this chain.
  • Heal, save-script, and fragments all go through the one writer.
  • Maestro export: a mixed chain projects to null (unsupported). A lone id now exports.

Validation

  • pnpm check:affected --run at c0bce3c: all runnable checks passed. CI covers the device lanes.
  • New writer cases: unique id gives the id alone, a shared android:id/title gives the chain without the id, and no id gives the chain. The unique-id case fails when the writer change is reverted. The drag and iOS save/replay tests now pin the lone-id line exactly.

🤖 Generated with Claude Code

A recorded element step whose id is unique in the record-time tree now
writes `id="..."` alone instead of the full `||` fallback chain. Steps
without a unique id keep the existing chain. The drag recorder uses the
same helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.39 MB 6.39 MB +411 B
Package (unpacked) 6.39 MB 6.39 MB +411 B
Package (download) 1.94 MB 1.94 MB +90 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 35.2 ms 30.9 ms -4.3 ms
CLI --help 63.0 ms 57.0 ms -6.0 ms

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of c0bce3c

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (f415b7da5a06).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at c0bce3c. CI is green (19 checks, none failing), and there are no conflicts. The writer, drag and replay-resolution routes read correctly, and the iOS save-and-replay test and the CI device lanes cover the lone-id replay.

Not blocking, and you can take or leave these: a record-unique id that is duplicated in the replay tree no longer falls through to role+label for get text or get attrs (it is now tiebroken or ambiguous), so the sentence at https://github.com/callstack/agent-device/blob/c0bce3c/packages/selectors/src/internal/build.ts#L79 could say it applies to acting steps; the divergence suggestion at https://github.com/callstack/agent-device/blob/c0bce3c/packages/replay-port/src/daemon-port/session-replay-divergence.ts#L669 still prints the || chain, so it could go through recordedSelectorExpression to match what recording writes; the new writer test re-declares the action() builder that other writer tests already have; and the PR body could mention that a lone id now exports to Maestro and that a renamed id now gives selector-miss instead of identity-mismatch for annotated steps.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 19, 2026
@thymikee
thymikee merged commit 1e698eb into main Nov 19, 2026
19 checks passed
@thymikee
thymikee deleted the t3/record-unique-id-only branch November 19, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant